﻿<!--#include file="base.asp"-->
<%
''' SDCMS 插件管理
''' ==================================================================
''' 版权所有 http://www.sdcms.cn
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: IT平民
''' 修改：IT平民 in 2014.07

	sub installdb()
		dim config:config=sdcms.enhtml(sdcms.fget("config",0))
		dim root:root=sdcms.enhtml(sdcms.fget("root",0))
		if sdcms.strlen(config)<=0 then
			sdcms.echo "0参数错误"
			exit sub
		end if
		dim data:data=array(array("setname","sdcms.plug",0),array("setkey",""&config&"",0),array("setvalue","true",0))
		if sdcms.db.dbnew("sd_config",data,"setname='sdcms.plug' and setkey='"&config&"'")=0 then
			sdcms.echo "0插件已存在，请勿重复安装"
			exit sub
		else
			get_sql root,5
			sdcms.echo "1插件安装成功！"
			sdcms.delcache "sdcmsdata"
		end if
	end sub
	
	sub uninstalldb()
		dim config:config=sdcms.enhtml(sdcms.fget("config",0))
		dim root:root=sdcms.enhtml(sdcms.fget("root",0))
		if sdcms.strlen(config)<=0 then
			sdcms.echo "0参数错误"
			exit sub
		end if
		sdcms.db.dbdel "sd_config","setname='sdcms.plug' and setkey='"&config&"'"
		get_sql root,6
		sdcms.echo "1插件卸载成功"
		sdcms.delcache "sdcmsdata"
	end sub
	
	sub get_sql(byval t0,byval t1)
		dim xml,t2
		set xml=server.createobject("microsoft.xmldom")
			xml.async=false
			xml.load(server.mappath("../plug/"&t0&"/config.xml"))
			t2=xml.documentelement.childnodes(t1).text
		set xml=nothing
		if sdcms.strlen(t2)<=0 then
			exit sub
		end if
		dim i,arr
		arr=split(t2,"@@")
		for i=0 to ubound(arr)
			sdcms.db.exedb arr(i)
		next
	end sub
	
	islogin
	checkpagelever 29
	dim act:act=lcase(sdcms.fget("act",0))
	select case act
		case "install":installdb
		case "uninstall":uninstalldb
		case else:load theme_plug
	end select
	sdcms.db.dbclose
%>